{include file="public/head"/}
<style>
  .main-content {
    margin-left: 0px;
    min-height: 80%;
    overflow: hidden;
  }

  .row .cf {
    margin-bottom: 10px;
  }

  .step-content {
    height: 560px;
  }

  .well {
    min-height: 90%;
  }

</style>


<div class="main-container" id="main-container">
  <script type="text/javascript">
    try {
      ace.settings.check('main-container', 'fixed')
    } catch (e) {
    }
  </script>

  <div class="main-container-inner">
    <a class="menu-toggler" id="menu-toggler" href="#">
      <span class="menu-text"></span>
    </a>
    {include file="public/nav"/}

    <div class="main-content">
      <div class="page-content">
        <div class="row">
          <div class="well">
            <h1 class=" lighter smaller">
              <span class="blue bigger-125">
                <i class="ace-icon fa fa-navicon"></i>
              </span>
              修改密码
            </h1>
            <hr>
            <div class="space"></div>

            <div class="row-fluid">
              <form class="form-horizontal" id="fmUser" method="post">
                <input type="hidden" name="id" value="{$user.id}">
                <div class="form-group">
                  <label class="col-sm-3 control-label no-padding-right"> 姓名 </label>
                  <div class="col-sm-9">
                    <input name="name" placeholder="姓名" class="col-xs-10 col-sm-5" value="{$user.name}" readonly>
                    <span class="help-inline col-xs-12 col-sm-7">
                    <span class="middle"></span>
                  </span>
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-3 control-label no-padding-right"> 登陆名 </label>
                  <div class="col-sm-9">
                    <input name="lname" placeholder="登陆名" class="col-xs-10 col-sm-5" value="{$user.lname}">
                    <!--<span class="help-inline col-xs-12 col-sm-7">
                        <span class="middle">注意需符合PHP变量名条件，前台调用：<literal></literal></span>
                    </span>-->
                  </div>
                </div>
                <div class="space-4"></div>
                <div class="form-group">
                  <label class="col-sm-3 control-label no-padding-right"> 原始密码 </label>
                  <div class="col-sm-9">
                    <input type="password" name="pwd" placeholder="原始密码" class="col-xs-10 col-sm-5" value="">
                    <span class="help-inline col-xs-12 col-sm-7">
                    <span class="middle"></span>
                  </span>
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-3 control-label no-padding-right"> 新密码 </label>
                  <div class="col-sm-9">
                    <input type="password" name="newpwd" placeholder="新密码" class="col-xs-10 col-sm-5" value="">
                    <span class="help-inline col-xs-12 col-sm-7">
                    <span class="middle"></span>
                  </span>
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-3 control-label no-padding-right"> 确认密码 </label>
                  <div class="col-sm-9">
                    <input type="password" name="renewpwd" placeholder="确认密码" class="col-xs-10 col-sm-5" value="">
                    <span class="help-inline col-xs-12 col-sm-7">
                    <span class="middle"></span>
                  </span>
                  </div>
                </div>

                <div class="col-md-offset-4 col-md-9">
                  <a class="btn btn-info" onclick="modifyPwd.doModifyPwd(this);">
                    <i class="icon-ok bigger-110"></i>
                    提交
                  </a>
                  <button class="btn" type="reset">
                    <i class="icon-undo bigger-110"></i>
                    重置
                  </button>
                </div>
              </form>
              <hr>
              <div class="space"></div>
            </div>
          </div><!-- /.row -->
        </div><!-- /.page-content -->
      </div><!-- /.main-content -->

    </div><!-- /.main-container-inner -->

    <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
      <i class="icon-double-angle-up icon-only bigger-110"></i>
    </a>
  </div>
</div>
  <!-- /.main-container -->
  {include file="public/footerjs"/}
  <script type="text/javascript">
    $(function(){
      $('#fmUser input[name=pwd]').blur(function(){
        var pwd=$(this).val();
        console.log(pwd);
        modifyPwd.checkPwd(pwd);
      })
    });
    modifyPwd={
      checkPwd:function(pwd){
        $.post('{:url("user/chkPwd")}',{pwd:pwd},function(data){
          if(data>0){
//            bootbox.alert("保存成功！");
//            setTimeout(function(){
//              location.href=addworksingleform_urls.indexWork;
//            },1000);
            $('#fmUser input[name=pwd]').next('span').find('span').text('原始密码正确').css('color','green');

          }else{
            $('#fmUser input[name=pwd]').next('span').find('span').text('原始密码错误').css('color','red');
//            bootbox.alert('保存失败！');
          }
        })
      },
      doModifyPwd:function(obj){
        var param=ittaoli.serializeObject($('#fmUser'));
        // console.log(param);

        if(param.newpwd!=param.renewpwd){
          bootbox.alert('两次新密码不一致哦~');
          return;
        }

        $(obj).button('loading');
        $.post('{:url("doModifyPwd")}',{param:JSON.stringify(param)},function(data){
          if(data>0){
            bootbox.alert("密码修改成功！请重新登陆");
            setTimeout(function(){
              location.href='{:url("admin/index/index")}';
            },1000);
          }else{
            bootbox.alert('修改失败！');
          }
          $(obj).button('reset');
        })
      }
    }

  </script>


  {include file="public/foot"/}
